feat: add unique constraints for NMA_WaterLevelsContinuous_Pressure_Daily and NGWMN tables#341
Conversation
…aily and NGWMN tables
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08b990d899
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def downgrade() -> None: | ||
| """Drop the NGWMN unique constraints if they exist.""" | ||
| op.execute( | ||
| """ | ||
| DO $$ | ||
| BEGIN | ||
| IF EXISTS ( | ||
| SELECT 1 FROM pg_constraint WHERE conname = 'uq_nma_view_ngwmn_waterlevels_point_date' | ||
| ) THEN | ||
| ALTER TABLE "NMA_view_NGWMN_WaterLevels" | ||
| DROP CONSTRAINT uq_nma_view_ngwmn_waterlevels_point_date; | ||
| END IF; |
There was a problem hiding this comment.
Keep NGWMN constraints when downgrading 5f4e2b0a6b8b
The downgrade here drops the NGWMN unique constraints even though they are originally introduced in an earlier migration (8a1de3e3f0b3). If someone downgrades from 5f4e2b0a6b8b to 4b7aa74b15ad, Alembic will run this block and remove constraints that should still exist at that revision, which can break the ON CONFLICT upserts for NGWMN backfills. Since this migration’s upgrade is only a conditional “ensure,” its downgrade should be a no-op (or only revert changes it made) to avoid leaving the schema in an invalid historical state.
Useful? React with 👍 / 👎.
Why
This PR addresses the following problem / context:
How
Implementation summary - the following was changed / added / removed:
Notes
Any special considerations, workarounds, or follow-up work to note?